package day1;

/**
 * @author pacai
 * @version 1.0
 */
public class SumArr {
    int[] sumArr;
    int[] arr;
    public static void setSumArr(int[] arr,int[] sumArr) {
        sumArr[0] = arr[0];
        for (int i = 1; i < arr.length; i++) {
            sumArr[i] = sumArr[i - 1] + arr[i];
        }
    }

    public static int getSum(int[] sumArr,int left,int right){
        return left == 0 ? sumArr[right] : -sumArr[left - 1] + sumArr[right];
    }
}
